package com.zlq.easydbutils;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;

import com.zlq.easydbutils.factory.EasyFactory;

public class BankDaoImpl implements BankDao {

	public Bank getBankByBank(String bank_no) throws SQLException {
		return EasyFactory.getRunner().query("select * from T_TEST where bank_no = ?", new BeanHandler<Bank>(Bank.class),bank_no);
	}
	
	public List getBankByBank2(String bank_no) throws SQLException {
		return EasyFactory.getRunner().querys("select \"bank_no\",\"bishu\" from T_TEST where \"bank_no\" != ? ", new BeanListHandler<Bank>(Bank.class),"1");
	}
	
	
	public List<Map<String, Object>> getBankByBankMap(String bank_no) throws SQLException {
		return EasyFactory.getRunner().querysMap("select \"bank_no\",\"bishu\" from T_TEST where \"bank_no\" != ? ", new MapListHandler(),"1");
	}
	public List getBankByBankArray(String bank_no) throws SQLException {
		return EasyFactory.getRunner().querys("select \"bank_no\",\"bishu\" from T_TEST where \"bank_no\" != ? ", new BeanListHandler<Bank>(Bank.class),"1");
	}

	public void addBank(Bank bank) throws SQLException {
		EasyFactory.getRunner().update("insert into T_TEST values(?,?,?,?,?,?)",bank.getBank_no(),"",bank.getBishu(),"","","");
	}
	
	public void updBank(Bank bank) throws SQLException {
		EasyFactory.getRunner().update("update  T_TEST set \"bishu\"=? where \"bank_no\"=?",bank.getBishu(),bank.getBank_no());
	}

}
